#include <iostream>

#include <vector>

 

using namespace std;

 

struct Node {

    Node(Node *n, int v) : next_(n), value(v){}

 

    Node *next_;

    int value;

};

 

struct Stack {

    Node *head = nullptr;

 

    void push(int value) {

        head = new Node(head, value);

    }

 

    void pop() {

        auto tmp = head;

        head = head->next_;

        delete tmp;

    }

 

    void print() {

        auto curr = head;

        while (curr) {

            cout << curr->value << ' ';

            curr = curr->next_;

        }

    }

    ~Stack(){

      while(head){

          pop();

      }

    }

};